package com.sj.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sj.entity.Article;
import com.sj.entity.Footprint;
import com.sj.entity.User;
import com.sj.mapper.FootprintMapper;
import com.sj.service.ArticleService;
import com.sj.service.FootprintService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 足迹表 服务实现类
 * </p>
 *
 * @author 孙峻
 * @since 2022-03-09
 */
@Service
public class FootprintServiceImpl extends ServiceImpl<FootprintMapper, Footprint> implements FootprintService {

    @Autowired
    private FootprintMapper footprintMapper;

    @Autowired
    private ArticleService articleService;

    @Override
    public IPage<Article> getFootPrintArticleByPage(User user, IPage<Article> articlePage) {
        return articleService.lambdaQuery().inSql(true, Article::getId, "select article_id from footprint where del = 0 and user_id = " + user.getId()).page(articlePage);
    }

    @Override
    public Long getUserFootprintNum(Integer id) {
        return footprintMapper.getUserFootprintNum(id);
    }
}
